﻿namespace HiMap.CoordinateSystem
{
    using HiMap.Base;
    using System;

    public class CoordinateSystemClass : HiMapPtrClass, ICoordinateSystem, IHiMapPtr, IDisposable
    {
        public CoordinateSystemClass(CoordinateSystemType Type)
        {
            base.m_InPtr = VC.KWG_COORDINATESYSTEM_CREATE_DEFINED((int) Type);
            base.m_Used = false;
        }

        public CoordinateSystemClass(int InPtr, bool Used)
        {
            base.m_InPtr = InPtr;
            base.m_Used = Used;
        }

        public void Dispose()
        {
            if (!base.m_Used && (base.m_InPtr != 0))
            {
                VC.KWG_COORDINATESYSTEM_DELETE(base.m_InPtr);
                base.m_InPtr = 0;
            }
        }

        public static double Distance(double x1, double y1, double x2, double y2)
        {
            double distance = 0;
            VC.KWG_COORDINATESYSTEM_GET_DISTANCE(x1, y1, x2, y2, ref distance);
            return distance;
        }

        ~CoordinateSystemClass()
        {
            if (!base.m_Used && (base.m_InPtr != 0))
            {
                VC.KWG_COORDINATESYSTEM_DELETE(base.m_InPtr);
            }
        }

        double ICoordinateSystem.A
        {
            get
            {
                double a = 0;
                VC.KWG_COORDINATESYSTEM_GET_A(base.m_InPtr, ref a);
                return a;
            }
        }

        double ICoordinateSystem.F
        {
            get
            {
                double f = 0;
                VC.KWG_COORDINATESYSTEM_GET_F(base.m_InPtr, ref f);
                return f;
            }
        }

        string ICoordinateSystem.Name
        {
            get
            {
                return "";
            }
        }

        CoordinateSystemType ICoordinateSystem.Type
        {
            get
            {
                return (CoordinateSystemType) VC.KWG_COORDINATESYSTEM_GET_TYPE(base.m_InPtr);
            }
        }
    }
}

